extends CharacterBody2D


const SPEED = 300.0
const JUMP_VELOCITY = -400.0
var ani:AnimatedSprite2D
@export var tag:String = "魔理沙"
@export var maxhp = 1500
@export var 分数 = 1
@export var 技能列表 = {}
var hp:int = 0
var flashtime = 0
var HPDrwa:TextureProgressBar
var hpshowtime:float = 0
func _ready() -> void:
	ani=$AnimatedSprite2D
	material = load("res://Code/Tools/敌人受击闪烁.gdshader")
	ani.sprite_frames = load("res://Code/enemy/"+tag+".tres")
	hp = maxhp
	HPDrwa = $"血条"
	HPDrwa.max_value = maxhp
	HPDrwa.min_value = 0
	HPDrwa.value = hp
	scale = Vector2(2,2)
	技能列表 = $"BOSS技能列表".selectBossObject(tag)
func _physics_process(delta: float) -> void:
	更新状态(delta)
	print(技能列表)
	if flashtime>0:
		flashtime-=1
		ani.material.blend_mode = 1
	else:
		ani.material.blend_mode = 0
		#velocity.x = direction * SPEED
		#velocity.x = move_toward(velocity.x, 0, SPEED)
	
	HPDrwa.value = hp
	move_and_slide()
func 被打(玩家:Node2D,子弹:Node2D):
	flashtime =4
	if 子弹.atk!=null:
		sethp(子弹.atk)
		hpshowtime = 5
	if hp<=0:
		GameData.分数+=分数
		end()
	pass
func end():
	self.queue_free()
func sethp(value:int):
	hp = hp - value
func 更新状态(dt:float):
	if hpshowtime >0:
		hpshowtime -= dt
	else:
		hpshowtime=0
	HPDrwa.visible = hpshowtime >0	
